﻿Imports Microsoft.VisualBasic
Imports System
Imports System.IO
Imports System.Net
Imports ChatEngine
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Media
Imports System.Windows.Media.Animation
Imports System.Windows.Navigation
Imports ChatEngine.ServerManagement
Partial Public Class ConnectToServer
    Dim ChatEngineInstance As ChatEngine.Client.IRCClient
    Dim textC As New System.Text.UTF8Encoding
    Dim toConvert() As Byte
    Dim b, a As String
    Public Sub New()
        MyBase.New()
        Me.InitializeComponent()
    End Sub
#Region " Buttons"
    Private Sub Close_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Close.MouseDown
        Dim ISC As New ImageSourceConverter
        Close.Source = ISC.ConvertFrom("pack://application:,,,/Images/Close-pressed.png")
    End Sub
    Private Sub Close_MouseEnter(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles Close.MouseEnter
        Dim ISC As New ImageSourceConverter
        Close.Source = ISC.ConvertFrom("pack://application:,,,/Images/close-hover.png")
    End Sub
    Private Sub Close_MouseLeave(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles Close.MouseLeave
        Dim ISC As New ImageSourceConverter
        Close.Source = ISC.ConvertFrom("pack://application:,,,/Images/close.png")
    End Sub
    Private Sub Close_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Close.MouseUp
        Dim ISC As New ImageSourceConverter
        Close.Source = ISC.ConvertFrom("pack://application:,,,/Images/close.png")
        Me.Hide()
    End Sub
    Private Sub Min_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Min.MouseDown
        Dim ISC As New ImageSourceConverter
        Min.Source = ISC.ConvertFrom("pack://application:,,,/Images/Minimize-pressed.png")
    End Sub
    Private Sub Min_MouseEnter(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles Min.MouseEnter
        Dim ISC As New ImageSourceConverter
        Min.Source = ISC.ConvertFrom("pack://application:,,,/Images/Minimize-hover.png")
    End Sub
    Private Sub Min_MouseLeave(ByVal sender As Object, ByVal e As System.Windows.Input.MouseEventArgs) Handles Min.MouseLeave
        Dim ISC As New ImageSourceConverter
        Min.Source = ISC.ConvertFrom("pack://application:,,,/Images/Minimize.png")
    End Sub
    Private Sub Min_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles Min.MouseUp
        Dim ISC As New ImageSourceConverter
        Min.Source = ISC.ConvertFrom("pack://application:,,,/Images/Minimize.png")
        Me.WindowState = Windows.WindowState.Minimized
    End Sub
#End Region
    Sub placeholder()
        SaveSetting("MChat", servername.Text, "User", Username.Text)
        SaveSetting("MChat", servername.Text, "Address", serveraddress.Text)
        toConvert = textC.GetBytes(Password.Text)
        b = Convert.ToBase64String(toConvert)
        SaveSetting("MChat", servername.Text, "Password", b)
        SaveSetting("MChat", "Settings", "DefaultChannel", servername.Text)
        SharedVars.CEInst.ConnectToServer(serveraddress.Text, 6667)
    End Sub
    Private Sub Connect_Click(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Connect.Click
        Dim CItem As Server = New Server
        toConvert = textC.GetBytes(Password.Text)
        b = Convert.ToBase64String(toConvert)
        CItem.address = serveraddress.Text
        CItem.name = servername.Text
        CItem.port = 6667
        CItem.password = b
        CItem.username = Username.Text
        SharedVars.Servers.Add(CItem)
    End Sub
End Class